<tuple-name> = tuple(collection)
lst=[4117, "Amit Jain", "Amravati"] tp=tuple(lst) print(tp) vstr = 'AEIOU' tp=tuple(vstr) print(tp)
(4117,"Amit Jain","Amravati") ('A','E','I','O','U')
Methods | |
---|---|
count(x) | Returns the number of items x. |
index(x) | Returns the index of the first item that is equal to x. |
Functions for Collections | |
---|---|
len(collection) | It returns its length. |
max(collection) | It returns the item with the highest value. |
min(collection) | It returns the item with the lowest value. |
sum(collection) | This function returns the arithmetic sum of all the items in the collection. |
sorted(collection) |
This function returns a sorted version of the collection as list. The sorting is in ascending order, and it doesn’t modify the original collection. |
lst=[] for i in range(3): nm=input("Enter Name :") ct=input("Enter City :") ag=input("Enter Age :") tp=(nm,ct,ag) lst.append(tp) print(lst)